package com.kma.summer2012.client.events.authorization;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.kma.summer2012.shared.model.UICrumbsUser;

public class AuthentificationEvent extends GwtEvent<AuthentificationEvent.AuthentificationEventHandler> {

    private static Type<AuthentificationEventHandler> TYPE = new Type<AuthentificationEventHandler>();
    private UICrumbsUser user;

    public AuthentificationEvent() {

    }

    public AuthentificationEvent(UICrumbsUser user) {
        this.user = user;
    }

    public UICrumbsUser getUser() {
        return user;
    }

    public interface AuthentificationEventHandler extends EventHandler {
        void onAuthentification(AuthentificationEvent event);
    }

    @Override
    public Type<AuthentificationEventHandler> getAssociatedType() {
        return TYPE;
    }

    public static Type<AuthentificationEventHandler> getType() {
        return TYPE;
    }

    @Override
    protected void dispatch(AuthentificationEventHandler handler) {
        handler.onAuthentification(this);
    }
}
